//
//  XhwWebViewController.m
//  SelfDriving
//
//  Created by 熊宏伟 on 2018/1/16.
//  Copyright © 2018年 apple. All rights reserved.
//
#define IOS8x ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define BASharedApplication [UIApplication sharedApplication]

/*! 用safari打开URL */
#define BA_OpenUrl(urlStr) [BASharedApplication openURL:[NSURL URLWithString:urlStr]]


#import "XhwWebViewController.h"
#import <WebKit/WebKit.h>
#import "XhwPlatFormView.h"
#import "BusinessService+User.h"
#import "ReportViewController.h"
#import "ReleaseMainVC.h"
#import "NewConversationVC.h"

@interface XhwWebViewController ()<WKNavigationDelegate,UIWebViewDelegate,XhwPlatFormViewDelegate,UIScrollViewDelegate>

@property (assign, nonatomic)NSUInteger loadCount;
@property (strong, nonatomic)UIProgressView *progressView;
@property (strong, nonatomic)UIWebView *webView;
@property (strong, nonatomic)WKWebView *wkWebView;

@end

@implementation XhwWebViewController
{
    UISlider* Slide;
    UIView *view;
    UIView *ZitiBackView;
    NSString *urls;
    UITextField *urltext;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [ZitiBackView removeFromSuperview];
    [view removeFromSuperview];
}

- (void)hideZitiView {
    [ZitiBackView removeFromSuperview];
    [view removeFromSuperview];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    //为了不让tableView 不延伸到 navigationBar 下面， 属性设置为 UIRectEdgeNone
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    
    [self configUI];
    [self configBackItem];
    [self configMenuItem];
}

#pragma mark -***** 进度条
- (UIProgressView *)progressView
{
    if (!_progressView)
    {
        UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 0)];
        progressView.tintColor = [UIColor greenColor];
        progressView.trackTintColor = [UIColor whiteColor];
        self.progressView = progressView;
    }
    return _progressView;
}

- (void)configUI
{
    self.progressView.hidden = NO;
    
    if (IOS8x) {
        WKWebView *wkWebView = [[WKWebView alloc] initWithFrame:self.view.bounds];
        wkWebView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
        wkWebView.backgroundColor = [UIColor whiteColor];
        wkWebView.navigationDelegate = self;
        
        /*! 适应屏幕 */
        //        wkWebView.scalesPageToFit = YES;
        /*! 解决iOS9.2以上黑边问题 */
        wkWebView.opaque = NO;
        /*! 关闭多点触控 */
        wkWebView.multipleTouchEnabled = YES;
        /*! 加载网页中的电话号码，单击可以拨打 */
        //        wkWebView.dataDetectorTypes = YES;
        
        [self.view insertSubview:wkWebView belowSubview:_progressView];
        
        [wkWebView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil];
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:_urlString]];
        [wkWebView loadRequest:request];
        self.wkWebView.scrollView.delegate = self;
        self.wkWebView = wkWebView;
    }
    else {
        UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
        webView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
        
        webView.backgroundColor = [UIColor whiteColor];
        webView.delegate = self;
        /*! 适应屏幕 */
        webView.scalesPageToFit = YES;
        /*! 解决iOS9.2以上黑边问题 */
        webView.opaque = NO;
        /*! 关闭多点触控 */
        webView.multipleTouchEnabled = YES;
        /*! 加载网页中的电话号码，单击可以拨打 */
        webView.dataDetectorTypes = YES;
        
        [self.view insertSubview:webView belowSubview:_progressView];
        
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:_urlString]];
        [webView loadRequest:request];
        self.webView = webView;
    }
}

#pragma mark 导航栏的返回按钮
- (void)configBackItem
{
    UIImage *backImage = [UIImage imageNamed:@"nav_back"];
    backImage = [backImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    UIButton *backBtn = [[UIButton alloc] init];
    [backBtn setTintColor:[UIColor orangeColor]];
    [backBtn setBackgroundImage:backImage forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(backBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [backBtn sizeToFit];
    
    UIBarButtonItem *colseItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = colseItem;
}

#pragma mark 导航栏的菜单按钮
- (void)configMenuItem
{
    UIImage *menuImage = [UIImage imageNamed:@"xxgd.png"];
    menuImage = [menuImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    UIButton *menuBtn = [[UIButton alloc] init];
    [menuBtn setTintColor:[UIColor orangeColor]];
    [menuBtn setImage:menuImage forState:UIControlStateNormal];
    [menuBtn addTarget:self action:@selector(menuBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [menuBtn sizeToFit];
    
    UIBarButtonItem *menuItem = [[UIBarButtonItem alloc] initWithCustomView:menuBtn];
    self.navigationItem.rightBarButtonItem = menuItem;
}

#pragma mark 导航栏的关闭按钮
- (void)configColseItem
{
    UIButton *colseBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 44, 44)];
    [colseBtn setTitle:@"关闭" forState:UIControlStateNormal];
    [colseBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [colseBtn addTarget:self action:@selector(colseBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [colseBtn sizeToFit];
    
    UIBarButtonItem *colseItem = [[UIBarButtonItem alloc] initWithCustomView:colseBtn];
    NSMutableArray *newArr = [NSMutableArray arrayWithObjects:self.navigationItem.leftBarButtonItem,colseItem, nil];
    self.navigationItem.leftBarButtonItems = newArr;
}

#pragma mark - ***** 按钮点击事件
#pragma mark 返回按钮点击
- (void)backBtnAction:(UIButton *)sender
{
    if (IOS8x) {
        if (self.wkWebView.canGoBack) {
            [self.wkWebView goBack];
            if (self.navigationItem.leftBarButtonItems.count == 1) {
                [self configColseItem];
            }
        }else {
            [self.navigationController popViewControllerAnimated:YES];
        }
    }else {
        if (self.webView.canGoBack) {
            [self.webView goBack];
            if (self.navigationItem.leftBarButtonItems.count == 1) {
                [self configColseItem];
            }
        }else {
            [self.navigationController popViewControllerAnimated:YES];
        }
    }
}
#pragma mark 菜单按钮点击
- (void)menuBtnAction:(UIButton *)sender
{
    [view removeFromSuperview];
    XhwPlatFormView * moreView = [[XhwPlatFormView alloc] init];
    moreView.delegate = self;
    [[UIApplication sharedApplication].delegate.window addSubview:moreView];
   
}

#pragma mark 关闭按钮点击
- (void)colseBtnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - WKNavigationDelegate 【该代理提供的方法，可以用来追踪加载过程（页面开始加载、加载完成、加载失败）、决定是否执行跳转。】
#pragma mark 页面开始加载时调用
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
{
    // 类似UIWebView的 -webViewDidStartLoad:
    NSLog(@"didStartProvisionalNavigation");
    BASharedApplication.networkActivityIndicatorVisible = YES;
}

#pragma mark 当内容开始返回时调用
- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation
{
    NSLog(@"didCommitNavigation");
}

#pragma mark 页面加载完成之后调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
    // 类似 UIWebView 的 －webViewDidFinishLoad:
    NSLog(@"didFinishNavigation");
    if (webView.title.length > 0)
    {
        self.title = webView.title;
    }
    
    // 获取内容高度
    //    CGFloat height =  [[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.scrollHeight"] intValue];
    //
    //    NSLog(@"html 的高度：%f", height);
}

#pragma mark 页面加载失败时调用
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
{
    // 类似 UIWebView 的- webView:didFailLoadWithError:
    NSLog(@"didFailProvisionalNavigation");
}

/*! 页面跳转的代理方法有三种，分为（收到跳转与决定是否跳转两种）*/
#pragma mark 接收到服务器跳转请求之后调用
- (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation
{
    
}

#pragma mark 在收到响应后，决定是否跳转
- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler
{
    decisionHandler(WKNavigationResponsePolicyAllow);
}

#pragma mark 在发送请求之前，决定是否跳转，如果不添加这个，那么wkwebview跳转不了AppStore
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
    if ([webView.URL.absoluteString hasPrefix:@"https://itunes.apple.com"])
    {
        BA_OpenUrl(navigationAction.request.URL);
        decisionHandler(WKNavigationActionPolicyCancel);
    }
    else
    {
        decisionHandler(WKNavigationActionPolicyAllow);
    }
}

- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString *))completionHandler
{
    completionHandler(@"Client Not handler");
}

#pragma mark 从web界面中接收到一个脚本时调用
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
{
    
}

#pragma mark 计算wkWebView进度条
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if (object == self.wkWebView && [keyPath isEqualToString:@"estimatedProgress"])
    {
        CGFloat newprogress = [[change objectForKey:NSKeyValueChangeNewKey] doubleValue];
        if (newprogress == 1)
        {
            self.progressView.hidden = YES;
            [self.progressView setProgress:0 animated:NO];
        }
        else
        {
            self.progressView.hidden = NO;
            [self.progressView setProgress:newprogress animated:YES];
        }
    }
}

#pragma mark - ***** dealloc 记得取消监听
- (void)dealloc
{
    if (IOS8x)
    {
        [self.wkWebView removeObserver:self forKeyPath:@"estimatedProgress"];
    }
}

#pragma mark - ***** UIWebViewDelegate
#pragma mark 计算webView进度条
- (void)setLoadCount:(NSUInteger)loadCount
{
    _loadCount = loadCount;
    if (loadCount == 0)
    {
        self.progressView.hidden = YES;
        [self.progressView setProgress:0 animated:NO];
    }
    else
    {
        self.progressView.hidden = NO;
        CGFloat oldP = self.progressView.progress;
        CGFloat newP = (1.0 - oldP) / (loadCount + 1) + oldP;
        if (newP > 0.95)
        {
            newP = 0.95;
        }
        [self.progressView setProgress:newP animated:YES];
    }
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    self.loadCount ++;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    self.loadCount --;
    BASharedApplication.networkActivityIndicatorVisible = NO;
    self.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
    
    // 获取内容高度
    CGFloat height =  [[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.scrollHeight"] intValue];
    
    NSLog(@"html 的高度：%f", height);
    
    //    CGFloat htmlHeight;
    //    // 防止死循环
    //    if (height != htmlHeight)
    //    {
    //
    //        htmlHeight = height;
    //
    //        if (height > 0)
    //        {
    //            // 更新布局
    //            CGFloat paddingEdge = 10;
    //            [webView mas_remakeConstraints:^(MASConstraintMaker *make) {
    //
    //                make.left.equalTo(self.view).with.offset(paddingEdge);
    //                make.right.mas_equalTo(-paddingEdge);
    //                make.top.equalTo(self.view).with.offset(paddingEdge);
    //                make.bottom.mas_equalTo(-paddingEdge);
    //
    //            }];
    //
    //            // 刷新cell高度
    ////            _viewModel.cellHeight = _viewModel.otherHeight + _viewModel.htmlHeight;
    ////            [_viewModel.refreshSubject sendNext:nil];
    //        }
    //        NSLog(@"html 的高度：%f", htmlHeight);
    //    }
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    self.loadCount --;
}

#pragma mark -xhwPlatformDelegate
- (void)btnClick:(UIButton *)sender {
    NSLog(@"%ld", (long)sender.tag);
    
    switch (sender.tag) {
        case 0:  //发送给朋友
        {
            UIStoryboard *customerStoryboard = [UIStoryboard storyboardWithName:@"MS"
                                                                         bundle:[NSBundle mainBundle]];
            NewConversationVC *searchResultDetailController = [customerStoryboard instantiateViewControllerWithIdentifier:@"NewConversationVC"];
            searchResultDetailController.webtype = @"webtype";
            searchResultDetailController.content = _urlString;
            [self.navigationController pushViewController:searchResultDetailController animated:YES];
            
            break;
        }
        case 1:  //分享到动态
        {
            UIStoryboard *customerStoryboard = [UIStoryboard storyboardWithName:@"Dynaminc"
                                                                         bundle:[NSBundle mainBundle]];
            ReleaseMainVC *searchResultDetailController = [customerStoryboard instantiateViewControllerWithIdentifier:@"ReleaseMainVC"];
            searchResultDetailController.ADUrl = _urlString;
            [self.navigationController pushViewController:searchResultDetailController animated:YES];
            break;
        }
        case 2:  //在sifari中代开
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:_urlString]];
            break;
        case 3:  //邮件
        {
            NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"mailto://%@",_urlString]];
            
            [[UIApplication sharedApplication] openURL:url];
            break;
        }
        case 4: //复制链接
        {
            UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
            pasteboard.string = _urlString;
            [SVProgressHUD showInfoWithStatus:@"已复制"];
            break;
        }
        case 6:  //刷新
            [self.wkWebView reload];
            break;
        case 7:  //举报
            
        {
            UIStoryboard *customerStoryboard = [UIStoryboard storyboardWithName:@"MS"
                                                                         bundle:[NSBundle mainBundle]];
            ReportViewController *searchResultDetailController = [customerStoryboard instantiateViewControllerWithIdentifier:@"ReportViewController"];
            
            
            searchResultDetailController.type = @"4";
            
            //            NSString *encodedValue = [_urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            //
            //            searchResultDetailController.content = encodedValue;
            searchResultDetailController.content = _ADid;
            
            [self.navigationController pushViewController:searchResultDetailController animated:YES];
            
            break;
        }
        case 5:  //调整字体
            
            
            view = [[UIView alloc]initWithFrame:CGRectMake(0, SCRE_HEIGHT - 90, SCRE_WIDTH, 90)];
            view.backgroundColor = UIColorFromRGB(0xf1f1f1);
            
            
            ZitiBackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCRE_WIDTH, SCRE_HEIGHT - 90)];
            UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideZitiView)];
            [ZitiBackView addGestureRecognizer:tapGes];
            ZitiBackView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
            [[[UIApplication sharedApplication] keyWindow] addSubview:ZitiBackView];
            
            UILabel *lable1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 5, SCRE_WIDTH/4, 30)];
            
            lable1.text = @"小";
            lable1.font = [UIFont systemFontOfSize:14];
            lable1.textAlignment = NSTextAlignmentCenter;
            [view addSubview:lable1];
            
            UILabel *lable2 = [[UILabel alloc]initWithFrame:CGRectMake(SCRE_WIDTH/4, 5, SCRE_WIDTH/4, 30)];
            
            lable2.text = @"标准";
            lable2.font = [UIFont systemFontOfSize:14];
            lable2.textAlignment = NSTextAlignmentCenter;
            
            [view addSubview:lable2];
            
            
            UILabel *lable3 = [[UILabel alloc]initWithFrame:CGRectMake((SCRE_WIDTH/4)*2, 5, SCRE_WIDTH/4, 30)];
            lable3.text = @"大";
            lable3.font = [UIFont systemFontOfSize:14];
            lable3.textAlignment = NSTextAlignmentCenter;
            
            [view addSubview:lable3];
            
            UILabel *lable4 = [[UILabel alloc]initWithFrame:CGRectMake((SCRE_WIDTH/4)*3, 5, SCRE_WIDTH/4, 30)];
            lable4.text = @"加大";
            lable4.font = [UIFont systemFontOfSize:14];
            lable4.textAlignment = NSTextAlignmentCenter;
            
            [view addSubview:lable4];
            
            
            Slide = [[UISlider alloc] initWithFrame:CGRectMake(0, 40, SCRE_WIDTH, 20)];
            [Slide addTarget:self action:@selector(SlideChange) forControlEvents:UIControlEventValueChanged];
            Slide.maximumValue = 150;
            Slide.minimumValue = 50;
            Slide.value = 50;
            [view addSubview:Slide];
            [ [ [ UIApplication  sharedApplication ]  keyWindow ] addSubview : view ] ;
            break;
    }
    
            
            
//        case 2:  //收藏
//        {
//            NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
//            [dic setObject:_urlString forKey:@"url"];
//            [[BusinessService shareInstance] netcollect:dic success:^(id result) {
//                [SVProgressHUD showSuccessWithStatus:@"收藏成功"];
//            } failure:^(id result) {
//                [SVProgressHUD showErrorWithStatus:@"收藏失败"];
//            }];
//            break;
//        }
//        case 3:  //在sifari中代开
//            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:_urlString]];
//            break;
//        case 4:  //邮件
//            {
//                NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"mailto://%@",_urlString]];
//
//                [[UIApplication sharedApplication] openURL:url];
//                break;
//            }
//        case 5: //复制链接
//            {
//                UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
//                pasteboard.string = _urlString;
//                [SVProgressHUD showInfoWithStatus:@"已复制"];
//                break;
//            }
//        case 7:  //刷新
//            [self.wkWebView reload];
//            break;
//        case 8:  //举报
//
//        {
//            UIStoryboard *customerStoryboard = [UIStoryboard storyboardWithName:@"MS"
//bundle:[NSBundle mainBundle]];
//            ReportViewController *searchResultDetailController = [customerStoryboard instantiateViewControllerWithIdentifier:@"ReportViewController"];
//
//
//            searchResultDetailController.type = @"4";
//
////            NSString *encodedValue = [_urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
////
////            searchResultDetailController.content = encodedValue;
//            searchResultDetailController.content = _ADid;
//
//            [self.navigationController pushViewController:searchResultDetailController animated:YES];
//
//            break;
//        }
//        case 6:  //调整字体
//
//
//            view = [[UIView alloc]initWithFrame:CGRectMake(0, SCRE_HEIGHT - 90, SCRE_WIDTH, 90)];
//            view.backgroundColor = UIColorFromRGB(0xf1f1f1);
//
//
//            ZitiBackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCRE_WIDTH, SCRE_HEIGHT - 90)];
//            UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideZitiView)];
//            [ZitiBackView addGestureRecognizer:tapGes];
//            ZitiBackView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
//            [[[UIApplication sharedApplication] keyWindow] addSubview:ZitiBackView];
//
//            UILabel *lable1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 5, SCRE_WIDTH/4, 30)];
//
//            lable1.text = @"小";
//            lable1.font = [UIFont systemFontOfSize:14];
//            lable1.textAlignment = NSTextAlignmentCenter;
//            [view addSubview:lable1];
//
//            UILabel *lable2 = [[UILabel alloc]initWithFrame:CGRectMake(SCRE_WIDTH/4, 5, SCRE_WIDTH/4, 30)];
//
//            lable2.text = @"标准";
//            lable2.font = [UIFont systemFontOfSize:14];
//            lable2.textAlignment = NSTextAlignmentCenter;
//
//            [view addSubview:lable2];
//
//
//            UILabel *lable3 = [[UILabel alloc]initWithFrame:CGRectMake((SCRE_WIDTH/4)*2, 5, SCRE_WIDTH/4, 30)];
//            lable3.text = @"大";
//            lable3.font = [UIFont systemFontOfSize:14];
//            lable3.textAlignment = NSTextAlignmentCenter;
//
//            [view addSubview:lable3];
//
//            UILabel *lable4 = [[UILabel alloc]initWithFrame:CGRectMake((SCRE_WIDTH/4)*3, 5, SCRE_WIDTH/4, 30)];
//            lable4.text = @"加大";
//            lable4.font = [UIFont systemFontOfSize:14];
//            lable4.textAlignment = NSTextAlignmentCenter;
//
//            [view addSubview:lable4];
//
//
//            Slide = [[UISlider alloc] initWithFrame:CGRectMake(0, 40, SCRE_WIDTH, 20)];
//            [Slide addTarget:self action:@selector(SlideChange) forControlEvents:UIControlEventValueChanged];
//            Slide.maximumValue = 150;
//            Slide.minimumValue = 50;
//            Slide.value = 50;
//            [view addSubview:Slide];
//            [ [ [ UIApplication  sharedApplication ]  keyWindow ] addSubview : view ] ;
//            break;
//        }
//
    
    
}

-(void)SlideChange
{
    NSString* str1 =[NSString stringWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%f%%'",Slide.value];
    [self.wkWebView evaluateJavaScript:str1 completionHandler:^(id _Nullable obj, NSError * _Nullable error) {
        if (error) {
            NSLog(@"error");
        }
    }];
    
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    [ZitiBackView removeFromSuperview];
    [view removeFromSuperview];
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    NSLog(@"哈哈哈");
}


@end
